package licode;

import java.util.Stack;

public class L283 {
    public static void moveZeroes(int[] nums) {
        Stack<Integer> stack = new Stack<>();

        for (int i=0;i<nums.length;i++){
           if (nums[i]!=0) {
               stack.push(nums[i]);
           }

        }
        for (int i=stack.size();i<nums.length;i++){
            nums[i]=0;
        }
        while (stack.size()>0){
            int i=stack.size()-1;
            Integer pop = stack.pop();
            nums[i--]=pop;
        }


    }

    public static void main(String[] args) {

        int[] ints = {0,1,0,3,12};
        moveZeroes(ints);
        for (int a: ints) {
            System.out.println(a);

        }

    }
}
